<?
session_start();

if (!isset($_SESSION["cart"]) OR empty($_SESSION["cart"]))
    header("Location: index.php");

include('templates/header.php');
?>
    <h1>Checkout</h1>
    <div class="table-cart">
        <table>
            <tr>
                <td></td>
                <td>Pid</td>
                <td>Product name</td>
                <td>Price per unit</td>
                <td>Qty</td>
                <td>Price</td>
            </tr>
            <?
            foreach ($_SESSION["cart"] as $cart_item) {
                echo "<tr id='item'><td><a href='javascript: removeItem(" . $cart_item["id"] . ")'><i class='icon-remove'></i></a></td><td>" . $cart_item["id"] . "</td><td><a href='product-detail.php?id={$cart_item['id']}'>" . $cart_item["itemname"] . "</a></td><td>" . $cart_item["itemprice"] . " €</td><td><button onclick='dcrcartItem({$cart_item['id']})' class='btn_qty'> - </button>" . $cart_item["itemqty"] . "<button onclick='ncrcartItem({$cart_item['id']})' class='btn_qty'> + </button></td><td>" . $cart_item["itemprice"] * $cart_item["itemqty"] . " €</td></tr>";
            }
            ?>
        </table>
        <div class="checkout-total">
            <strong><?= $totalPrice ?> €</strong>
        </div>
        <div class="checkout-paynow">
            <input type="text" name="email" id="email" placeholder="Email address">
            <a onclick="return checkEmail();" href="javascript: void(0);">
                <button class="btn_paynow">PAY NOW</button>
            </a>
        </div>
    </div>
<? include('templates/footer.php'); ?>